﻿<phone:PhoneApplicationPage 
    x:Class="DDU.Curriculum.Views.ActivityAddView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
    xmlns:Converters="clr-namespace:DDU.Converters;assembly=DDU.Converters"
    xmlns:UX="clr-namespace:DDU.UX;assembly=DDU.UX"
    xmlns:viewmodel="clr-namespace:DDU.ViewModel;assembly=DDU.ViewModel"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait" Orientation="Portrait"
    mc:Ignorable="d" d:DesignHeight="800" d:DesignWidth="480"
    shell:SystemTray.IsVisible="False">
    <phone:PhoneApplicationPage.Resources>
        <Converters:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
    </phone:PhoneApplicationPage.Resources>
    <Grid x:Name="LayoutRoot">
        <Grid.DataContext>
            <viewmodel:ActivityAddViewModel/>
        </Grid.DataContext>
        <Grid.Background>
            <ImageBrush ImageSource="/Assets/back.png"/>
        </Grid.Background>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
            <TextBlock Text="{StaticResource IDS_APP_NAME}" Style="{StaticResource PhoneTextNormalStyle}"/>
            <TextBlock Text="添加活动信息" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
        </StackPanel>

        <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
            <Grid.ColumnDefinitions>
                <ColumnDefinition/>
                <ColumnDefinition Width="auto"/>
            </Grid.ColumnDefinitions>

            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition/>
                    <RowDefinition Height="auto"/>
                </Grid.RowDefinitions>

                <ScrollViewer>
                    <StackPanel>
                        <TextBlock Style="{StaticResource PhoneTextSubtleStyle}" Text="标题"/>
                        <TextBox Text="{Binding ActivityToAdd.Title, Mode=TwoWay}"/>
                        <TextBlock Style="{StaticResource PhoneTextSubtleStyle}" Text="活动内容"/>
                        <TextBox Text="{Binding ActivityToAdd.Content, Mode=TwoWay}" AcceptsReturn="True" TextWrapping="Wrap"/>
                        <TextBlock Style="{StaticResource PhoneTextSubtleStyle}" Text="地点"/>
                        <TextBox Text="{Binding ActivityToAdd.Location, Mode=TwoWay}"/>

                        <CheckBox Content="课外" IsChecked="{Binding ActivityToAdd.AfterClass, Mode=TwoWay}"/>
                        <CheckBox Content="全天" IsChecked="{Binding ActivityToAdd.AllDayActivity, Mode=TwoWay}" Grid.Column="1"/>
                        
                        <TextBlock Style="{StaticResource PhoneTextSubtleStyle}" Text="开始时间"/>
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition/>
                                <ColumnDefinition/>
                            </Grid.ColumnDefinitions>
                            <toolkit:DatePicker Value="{Binding ActivityToAdd.StartTime, Mode=TwoWay}"/>
                            <toolkit:TimePicker Value="{Binding ActivityToAdd.StartTime, Mode=TwoWay}" Grid.Column="1"/>
                        </Grid>
                        <TextBlock Style="{StaticResource PhoneTextSubtleStyle}" Text="结束时间"/>
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition/>
                                <ColumnDefinition/>
                            </Grid.ColumnDefinitions>
                            <toolkit:DatePicker Value="{Binding ActivityToAdd.EndTime, Mode=TwoWay}"/>
                            <toolkit:TimePicker Value="{Binding ActivityToAdd.EndTime, Mode=TwoWay}" Grid.Column="1"/>
                        </Grid>

                    </StackPanel>
                </ScrollViewer>

                <StackPanel Grid.Row="1" Margin="0,0,0,12">
                    <TextBlock Style="{StaticResource PhoneTextTitle2Style}" Text="持续时间"/>
                    <TextBlock Style="{StaticResource PhoneTextSubtleStyle}" >
                        <Run Text="{Binding ActivityToAdd.Duration,StringFormat=\{0:F1\}}"/>
                        <Run Text=" 小时"/>
                    </TextBlock>
                    <TextBlock Text="时间设置出错：结束时间不能先于开始时间" Style="{StaticResource PhoneTextAccentStyle}" Visibility="{Binding Path=TimeError, Converter={StaticResource BooleanToVisibilityConverter}}" />
                </StackPanel>
            </Grid>
            
            
            <StackPanel Grid.Column="1" VerticalAlignment="Bottom">
                <UX:UXPathButton IconPath="{Binding Mode=OneWay, Source={StaticResource PATH_ICON_SUBMIT}}" Command="{Binding AddCommand, Mode=OneWay}" />
                <UX:UXPathButton IconPath="{Binding Mode=OneWay, Source={StaticResource PATH_ICON_CLOSE}}" Command="{Binding CancelCommand, Mode=OneWay}" Padding="13" Margin="0,12,0,12"/>
            </StackPanel>
        </Grid>
    </Grid>
 
    <!--Sample code showing usage of ApplicationBar-->
    <!--<phone:PhoneApplicationPage.ApplicationBar>
        <shell:ApplicationBar IsVisible="True" IsMenuEnabled="True">
            <shell:ApplicationBarIconButton IconUri="/Images/appbar_button1.png" Text="Button 1"/>
            <shell:ApplicationBarIconButton IconUri="/Images/appbar_button2.png" Text="Button 2"/>
            <shell:ApplicationBar.MenuItems>
                <shell:ApplicationBarMenuItem Text="MenuItem 1"/>
                <shell:ApplicationBarMenuItem Text="MenuItem 2"/>
            </shell:ApplicationBar.MenuItems>
        </shell:ApplicationBar>
    </phone:PhoneApplicationPage.ApplicationBar>-->

</phone:PhoneApplicationPage>
